//
//  U9CommentManager.m
//  U9WatchGame
//
//  Created by uuu9 on 2018/7/23.
//  Copyright © 2018年 UUU9. All rights reserved.
//

#import "U9CommentManager.h"
#import "U9CommentModel.h"

@implementation U9CommentManager


//提交参数（必填）：site站点标识，aid文章id，content评论内容，title评论标题，cid频道id，url文章地址

+ (void)commentNewsWithNewsID:(NSString *)newsID andContent:(NSString *)content andSite:(NSString *)site andCid:(NSString *)channelid andTitle:(NSString *)title andUrl:(NSString *)url andName:(NSString *)name andImg:(NSString *)img andCompletionHandle:(void (^)(U9CommentModel *model, NSError *error))complete{
    
    NSString *param = [NSString stringWithFormat:@"channelid=%@&site=%@&url=%@&aid=%@&content=%@&title=%@&nickname=%@&img=%@",channelid,site,url,newsID,content,title,getStr(name),getStr(img)];

    [self CommentPOST:[NSString stringWithFormat:@"%@%@",Comment_URL,kPostComment]
    parameters:param
completionHandler:^(id responseObj, NSError *error) {
    U9CommentModel *model = [U9CommentModel mj_objectWithKeyValues:responseObj];
    if ([responseObj isEqualToString:@"false"]) {
        error = [self createError:@"error"];
    }
    complete(model,error);
}];
}

+(void)getCommentListWithNewsID:(NSString *)newsID andChannelID:(NSString *)channelID andPage:(NSString *)p andSite:(NSString *)site andCompletionHandle:(void (^)(U9CommentModel *model, NSError *error))complete{
    [self POST:[NSString stringWithFormat:@"%@%@?site=%@&aid=%@&channelid=%@&p=%@",Comment_URL,kGetCommentList,site,newsID,channelID,p]
   parameters:nil
completionHandler:^(id responseObj, NSError *error) {
    U9CommentModel *model = [U9CommentModel mj_objectWithKeyValues:responseObj];
    if (model.status != 1) {
        error = [self createError:@"error"];
    }
    complete(model,error);
}];
    
}


@end
